//
// Created by HP on 2024/4/14.
//

#ifndef AURORA_ST_COMMON_THREAD_DEFINE_H
#define AURORA_ST_COMMON_THREAD_DEFINE_H



#define PARAM_VALID         0x5A
#define PARAM_DISVALID      0x1B

#define LEFT_MOTOR_ID       0x01
#define RIGHT_MOTOR_ID      0x02

typedef enum Aurora_CMD{
    IS_NONE = 0, //无操作
    IS_CMD ,     //是命令
    IS_DATA,     //是数据
}Aurora_CMD;

#pragma pack(1)
union float_uint32_int_char{
    uint32_t u32_data;
    char  data[4];
    float f;
};

//通讯的数据包结构
#pragma pack(1)
struct COMM_MSG_PACKAGE{
    uint8_t head;
    uint8_t func1;
    uint8_t func2;
    uint8_t func3;
    union float_uint32_int_char data1;
    union float_uint32_int_char data2;
    union float_uint32_int_char data3;
    union float_uint32_int_char data4;
    uint8_t reserve[3];
    uint8_t tail;
};

#pragma pack(1)
typedef struct FOC_PARAMETER_STORAGE_VALUE{
    uint8_t storage_flag;
    uint8_t Pole_Pair;
    uint8_t motor_rotate_direct;
    union float_uint32_int_char mechanical_offset;
    union float_uint32_int_char UqUd_Limit_Max;
    union float_uint32_int_char IqId_Limit_Max;
    union float_uint32_int_char Iq_P;
    union float_uint32_int_char Iq_I;
    union float_uint32_int_char Id_P;
    union float_uint32_int_char Id_I;
    union float_uint32_int_char Speed_P;
    union float_uint32_int_char Speed_I;
    union float_uint32_int_char Position_P;
    union float_uint32_int_char Position_I;
}FOC_PARAMETER_STORAGE_VALUE;

#pragma pack(1)
typedef struct UI_PARAMETER_STORAGE{
    uint8_t aim_flag;  //开机动画
    uint8_t aim_num;   //开机动画张数
    uint8_t img_flag;
    uint8_t img_num;
    uint8_t font_big_flag;
    uint8_t font_middle_flag;
    uint8_t font_small_flag;
}UI_PARAMETER_STORAGE;


#pragma pack(1)
typedef struct FOC_PARAMETER_STORAGE{
    FOC_PARAMETER_STORAGE_VALUE L_FOC_PARM;
    FOC_PARAMETER_STORAGE_VALUE R_FOC_PARM;
}FOC_PARAMETER_STORAGE;


#pragma pack(1)
typedef struct Firmware_PARAMETER_STORAGE{
    uint8_t main_version;     //主版本号
    uint8_t minor_version;    //次版本号
    uint32_t firmware_size;   //固件大小
}Firmware_PARAMETER_STORAGE;



#endif //AURORA_ST_COMMON_THREAD_DEFINE_H
